import time
print('executed')
'必须用绝对路径'
f = open("C:/Users/GZH/Desktop/HTML/res1.txt", "w")
f.write('before interact \n')
f.close()
state1 = open("C:/Users/GZH/Desktop/HTML/res2.txt", "w")
state1.write('after interact \n')
state1.close()

# while 1:
#     time.sleep(1)
#     print('executed')
res = 0    
write_flag = 0
for i in range(10):
    res = i 
    f = open("C:/Users/GZH/Desktop/HTML/res1.txt", "a")
    f.write(str(res)   +'\n')
    f.close()
    if write_flag :
        state1 = open("C:/Users/GZH/Desktop/HTML/res2.txt", "a")
        state1.write(str(res)+ '\n')
        state1.close()
    if res == 6:
        while (1):
            print('等待前端输入')
            time.sleep(1)
            human = open("C:/Users/GZH/Desktop/HTML/human.txt",'r+')
            continue_flag = human.readline()
            continue_flag=continue_flag.strip('\n')
            if len(continue_flag):
                human_answer = continue_flag
                state1 = open("C:/Users/GZH/Desktop/HTML/res2.txt", "a")
                state1.write('human_input:'+str(human_answer)+ '\n')
                state1.close()
                write_flag = 1
                human.seek(0)
                human.truncate()
                human.close()
                break
            human.close()

